SPB Git forge

spb/rareindex

Public
54commits 1branches 0releases
7.1 MBsize
maindefault branch
10 days agolast push
TypeScript 61.9% HTML 37.2% SQL 0.7%
754 B · 14 lines typescript
Raw Blame History
1import { NextResponse } from 'next/server';2import { readUpload } from '@/lib/account/uploads';34export const dynamic = 'force-dynamic';56/** Serves member uploads. Avatars and photos of public collections are public; ids are unguessable (100-bit). */7export async function GET(_req: Request, ctx: { params: Promise<{ id: string }> }) {8  const { id } = await ctx.params;9  if (!/^img_[0-9a-z]{20}$/.test(id)) return new NextResponse('Not found', { status: 404 });10  const up = await readUpload(id);11  if (!up) return new NextResponse('Not found', { status: 404 });12  return new NextResponse(new Uint8Array(up.buf), { headers: { 'content-type': up.mime, 'cache-control': 'public, max-age=31536000, immutable', 'x-content-type-options': 'nosniff' } });13}14